import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;

public class Product {

    String code;
    String description;
    double price;
    Date productionDate;
    String shelfLife;

    public String getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }

    public double getPrice() {
        return price;
    }

    public Date getProductionDate() {
        return productionDate;
    }

    public String getShelfLife() {
        return shelfLife;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Product product = (Product) o;
        return Double.compare(product.price, price) == 0 && code.equals(product.code) && description.equals(product.description) && productionDate.equals(product.productionDate) && shelfLife.equals(product.shelfLife);
    }

    @Override
    public String toString() {
        return "Product{" +
                "code='" + code + '\'' +
                ", description='" + description + '\'' +
                ", price=" + price +
                ", productionDate=" + productionDate +
                ", shelfLife='" + shelfLife + '\'' +
                '}';
    }

    public Product(String code, String description, double price, Date productionDate, String shelfLife) {
        this.code = code;
        this.description = description;
        this.price = price;
        this.productionDate = productionDate;
        this.shelfLife = shelfLife;
    }

    public static void main(String[] args) {
        List<Product> products= new ArrayList<>();

        products.add(new Jelly("123","hao",10.0, new Date(2021,5,6), "12 months", "sweet"));
        products.add(new Yogurt("13","aadao",10.0, new Date(2019,7,15), "3 months", "cool", "75%" ));
        products.add(new PureMilk("1523", "kkk",10.0, new Date(2020,7,15), "3 months", "China", "good", "good"));
        products.add(new MilkDrink("12663","aao",10.0, new Date(2022,9,15), "3 months", "beautiful", "while"));

        for (int i = 0; i < products.size(); i++) {
            System.out.println(products.get(i).toString());
        }
    }
}
